package main.Q2601_2700;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Q2651_2660 {
    public static void main(String[] args) {
        System.out.println("Question2651：");
        System.out.println("Question2652：倍数求和");
        System.out.println("Question2653：");
        System.out.println("Question2654：");
        System.out.println("Question2655：");
        System.out.println("Question2656：K个元素的最大和");
        System.out.println("Question2657：找到两个数组的前缀公共数组");
        System.out.println("Question2658：");
        System.out.println("Question2659：");
        System.out.println("Question2660：");
    }
}

class Question2652 {
    public int sumOfMultiples(int n) {
        int result = 0, p3 = 3, p5 = 5, p7 = 7;
        while (p3 <= n || p5 <= n || p7 <= n) {
            if (p3 <= n && (p3 % 5 != 0 && p3 % 7 != 0)) {
                result += p3;
            }
            if (p5 <= n && (p5 % 7 != 0)) {
                result += p5;
            }
            if (p7 <= n) {
                result += p7;
            }
            p3 += 3;
            p5 += 5;
            p7 += 7;
        }
        return result;
    }
}

class Question2656 {
    public int maximizeSum(int[] nums, int k) {
        Arrays.sort(nums);
        int max = nums[nums.length - 1], result = 0;
        for (int i = 0; i < k; i++) {
            result += max + i;
        }
        return result;
    }
}

class Question2657 {
    public int[] findThePrefixCommonArray(int[] A, int[] B) {
        int[] result = new int[A.length];
        Set<Integer> setA = new HashSet<>(), setB = new HashSet<>();
        int count = 0;
        for (int i = 0; i < A.length; i++) {
            setA.add(A[i]);
            setB.add((B[i]));
            if (setA.contains(B[i])) {
                count += 1;
            }
            if (setB.contains(A[i])) {
                count += 1;
            }
            if (A[i] == B[i]) {
                count--;
            }
            result[i] = count;

        }
        return result;
    }
}